<?php
class DailyView extends Control {
	var $MonthDecorator ;
	var $Month ;
	var $Cal ;
	var $Events ;
	var $cE ;
	var $tableHelper ;
	var $year ;
	var $month ;
	var $firstDay = false ;
	
	function DailyView ( &$Context ) {
		$this->Name = 'DailyView' ;
		$this->Control ( $Context ) ;
		require_once CALENDAR_ROOT . 'Month/Weekdays.php' ;
		require_once CALENDAR_ROOT . 'Day.php' ;
		require_once CALENDAR_ROOT . 'Decorator.php' ;
		require_once CALENDAR_ROOT . 'Table/Helper.php' ;
		require_once VCAL_ROOT . 'library/Class.DiaryEvent.php' ;
		require_once VCAL_ROOT . 'library/Class.MonthPayload_Decorator.php' ;
		
		$this->Cal = new Calendar ( ) ;
		$this->tableHelper = & new Calendar_Table_Helper ( $this->Cal, $this->firstDay ) ;
		$this->Month = & new Calendar_Month_Weekdays ( date ( "Y" ), date ( "m" ) ) ;
		$this->MonthDecorator = new MonthPayload_Decorator ( $this->Month ) ;
	}
	function GetEventsFromDateRange ( $Start , $End ) {
		$EventManager = $this->Context->ObjectFactory->NewContextObject ( $this->Context, 'EventManager' ) ;
		$EventManager->GetEventByDateRange ( $Start, $End ) ;
		
		foreach ( $EventManager->Events as $Event ) {
			
			$this->Events[] = array ( 'Start' => $Event->StartDate . ' ' . $Event->StartTime , 'End' => $Event->EndDate . ' ' . $Event->EndTime , 'Name' => $Event->Name , 'Title' => $Event->Title , 'Color' => $Event->Color , 'Link' => GetUrl ( $Configuration, 'comments.php', '', 'DiscussionID', $Event->DiscussionID, '', '' ) ) ;
		
		}
		
		$this->MonthDecorator->build ( $this->Events ) ;
	}
	
	function Render () {
		//$this->GetMonthBounds();
		$this->GetEventsFromDateRange ( date ( "Y-m-d", mktime ( 0, 0, 0, date ( "m" ), 22, date ( "Y" ) ) ), date ( "Y-m-d", mktime ( 0, 0, 0, date ( "m" ), 22, date ( "Y" ) ) ) ) ;
		include VCAL_ROOT . 'theme/Theme.DayView.php' ;
	}

}
?>
